package com.arm.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.arm.common.utils.StringUtils;
import com.arm.system.domain.ArmEquipmentinfo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.arm.common.annotation.Log;
import com.arm.common.core.controller.BaseController;
import com.arm.common.core.domain.AjaxResult;
import com.arm.common.enums.BusinessType;
import com.arm.system.service.IArmEquipmentinfoService;
import com.arm.common.utils.poi.ExcelUtil;
import com.arm.common.core.page.TableDataInfo;

/**
 * 被装信息管理Controller
 * 
 * @author arm
 * @date 2023-11-06
 */
@RestController
@RequestMapping("/system/equipmentinfo")
public class ArmEquipmentinfoController extends BaseController
{
    @Autowired
    private IArmEquipmentinfoService armEquipmentinfoService;

    /**
     * 查询被装信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:equipmentinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArmEquipmentinfo armEquipmentinfo)
    {
        startPage();
        List<ArmEquipmentinfo> list = armEquipmentinfoService.selectArmEquipmentinfoList(armEquipmentinfo);
        return getDataTable(list);
    }

    /**
     * 查询被装信息管理列表
     */
    @GetMapping("/listVo")
    public TableDataInfo listVo(ArmEquipmentinfo armEquipmentinfo)
    {
        startPage();
        List<ArmEquipmentinfo> list = armEquipmentinfoService.selectArmEquipmentinfoVoList(armEquipmentinfo);
        return getDataTable(list);
    }
    /**
     * 导出被装信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:equipmentinfo:export')")
    @Log(title = "被装信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArmEquipmentinfo armEquipmentinfo)
    {
        List<ArmEquipmentinfo> list = armEquipmentinfoService.selectArmEquipmentinfoList(armEquipmentinfo);
        ExcelUtil<ArmEquipmentinfo> util = new ExcelUtil<ArmEquipmentinfo>(ArmEquipmentinfo.class);
        util.exportExcel(response, list, "被装信息管理数据");
    }

    /**
     * 获取被装信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:equipmentinfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(armEquipmentinfoService.selectArmEquipmentinfoById(id));
    }

    /**
     * 新增被装信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:equipmentinfo:add')")
    @Log(title = "被装信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArmEquipmentinfo armEquipmentinfo)
    {
        if (StringUtils.isBlank(armEquipmentinfo.getState())){
            armEquipmentinfo.setState("storage");
        }
        return toAjax(armEquipmentinfoService.insertArmEquipmentinfo(armEquipmentinfo));
    }

    /**
     * 修改被装信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:equipmentinfo:edit')")
    @Log(title = "被装信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArmEquipmentinfo armEquipmentinfo)
    {
        return toAjax(armEquipmentinfoService.updateArmEquipmentinfo(armEquipmentinfo));
    }

    /**
     * 删除被装信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:equipmentinfo:remove')")
    @Log(title = "被装信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(armEquipmentinfoService.deleteArmEquipmentinfoByIds(ids));
    }
}
